package com.example.movie.mate.service.impl;

import com.example.movie.mate.dao.mapper.HallMapper;
import com.example.movie.mate.dao.mapper.SeatMapper;
import com.example.movie.mate.exception.ServiceException;
import com.example.movie.mate.pojo.vo.HallVO;
import com.example.movie.mate.pojo.vo.SeatVO;
import com.example.movie.mate.service.ISeatService;
import com.example.movie.mate.web.StateCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class SeatServiceImpl implements ISeatService {

    @Autowired
    private HallMapper hallMapper;
    @Autowired
    private SeatMapper seatMapper;

    @Override
    public List<SeatVO> selectByHallId(Long hallId) {
        HallVO hall = hallMapper.selectById(hallId);
        if (hall == null) {
            throw new ServiceException(StateCode.ERROR_NOT_FOUND, "影厅不存在");
        }
        return seatMapper.selectByHallId(hallId);
    }

}